#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;

int main() {
    ifstream input("INPUT.txt", ifstream::in);

    int dataAmount;
    input >> dataAmount;

    double* Data = new double[dataAmount];
    for (int i = 0; i < dataAmount; ++i, cin >> Data[i]);

    int sizeofRMQ = (int)floor(log((double)dataAmount) / log(2.0)) + 1;

    int** RMQ = new int*[dataAmount];
    for (int i = 0; i < dataAmount; ++i, RMQ[i] = new int[sizeofRMQ]);
    for (int i = 0; i < dataAmount; ++i, RMQ[i][0] = i);

	//Brave New RMQ
    for (int i = 1; i < sizeofRMQ; ++i) {
        for (int k = 0; k < dataAmount - (1<<i) + 1; ++k) {
            if (Data[ RMQ[k][i - 1] ] < Data[ RMQ[k + (1<<(i-1))][i-1] ]) {
                 RMQ[k][i] = RMQ[k][i - 1];
            } else {
                 RMQ[k][i] = RMQ[k + (1<<(i-1))][i-1];
            }
        }
    }

    int requestCount;
    cin >> requestCount; 

	//feel like a wizard
    while (requestCount > 0) {
		requestCount--;
        int i, j;
        cin >> i >> j;
        j--; //because logic of acm.mipt is rather strange

        int k = (int)floor(log((double)j - i + 1) / log(2.0));
        cout << min(Data[RMQ[i][k]], Data[RMQ[j - (1<<k) + 1][k]])<<endl;
    }

	delete(RMQ);

    system("pause");
    return 0;
}